/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author antonio
 */
@Entity
@PrimaryKeyJoinColumn(name = "username")
@Table(name = "Player")
@DiscriminatorValue("PLAYER")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Player.findAll", query = "SELECT p FROM Player p"),
    @NamedQuery(name = "Player.findByUsername", query = "SELECT p FROM Player p WHERE p.username = :username")})
public class Player extends User {

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "player1")
    private Collection<Storage> storageCollection;
    @JoinColumn(name = "era", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Era era;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "player1")
    private Collection<Ownership> ownershipCollection;

    public Player() {
    }

    @XmlTransient
    public Collection<Storage> getStorageCollection() {
        return storageCollection;
    }

    public void setStorageCollection(Collection<Storage> storageCollection) {
        this.storageCollection = storageCollection;
    }

    public Era getEra() {
        return era;
    }

    public void setEra(Era era) {
        this.era = era;
    }

    @XmlTransient
    public Collection<Ownership> getOwnershipCollection() {
        return ownershipCollection;
    }

    public void setOwnershipCollection(Collection<Ownership> ownershipCollection) {
        this.ownershipCollection = ownershipCollection;
    }
    
}
